//Verified on 5/12/12

#include <Arduino.h>

#ifndef _FOUR_WHEEL_BASE_H_
#define _FOUR_WHEEL_BASE_H_

class Base
{
//base control function
public:
  void moveForward(int speed); //speed is in percent -at 100% bot moves forward with meanspeed
  void moveForward(int flspeed, int frspeed, int blspeed, int brspeed); //set the speed of each wheel individually- here too speeds are to be set in percent
  void moveBackward(int speed);//if speed equals 200% the each wheel in the bot will rotate with 2 times the meanspeed
  void moveBackward(int flspeed, int frspeed, int blspeed, int brspeed); //speed of each wheel can be set individually as the bot move backwards
  void moveLeft(int speed); //bot moves left without turning - only mecanam wheels can do this
  void moveLeft(int flspeed, int frspeed, int blspeed, int brspeed); //bot moves left without turning and speeds of each wheel can be set
  void moveRight(int right); //bot moves right without turning - mecanam wheel only
  void moveRight(int flspeed, int frspeed, int blspeed, int brspeed); //spare me. read the above comments.

  void rotateRight(int);//not implemented yet do not use
  void rotateRight(int flspeed, int frspeed, int blspeed, int brspeed); //dont use
  void rotateLeft(int); //dont use
  void rotateLeft(int flspeed, int frspeed, int blspeed, int brspeed); //dont use . not yet

  void stop(); //stops the bot and locks the motors

  void setPwm(int speed); //sets the PWM values of each wheel corresponding to the percentage given. speed=90% means that each wheels will run at 90% of their respective meanspeeds
  void setPwm(int flspeed, int frspeed, int blspeed, int brspeed); //overloaded setPwm(). does the same as the one above, but speeds can be set individually
//base initialization functions
public:
  void attachMotors(int fldir1,int fldir2,int flpwm, \
			  int frdir1,int frdir2,int frpwm, \
			  int bldir1,int bldir2,int blpwm, \
			  int brdir1,int brdir2,int brpwm); //passes the pins of the motors to the class instance
  void setMeanSpeeds(int flmeanspeed,int frmeanspeed,int blmeanspeed,int brmeanspeed); //pwm values corresponding to meanspeeds are set
//query functions
public:

  int flSpeed();
  int frSpeed();
  int blSpeed();
  int brSpeed();

  int flMeanSpeed();
  int frMeanSpeed();
  int blMeanSpeed();
  int brMeanSpeed();
  int MovementVal();


  bool isMovingForward();
  bool isMovingBackward();
  bool isMovingRight();
  bool isMovingLeft();
//all informationa about pins and meanspeeds are stored here
private:
  int FLDir1;
  int FLDir2;
  int FLPwm;
  int FRDir1;
  int FRDir2;
  int FRPwm;
  int BLDir1;
  int BLDir2;
  int BLPwm;
  int BRDir1;
  int BRDir2;
  int BRPwm;

  int FLMeanspeed;
  int FRMeanspeed;
  int BLMeanspeed;
  int BRMeanspeed;

private:
  int FLSpeed; //the current pwm of FL motor
  int FRSpeed; // "    "        "       "
  int BLSpeed; //  "      "      "  "
  int BRSpeed; // "      "     "      "
  int movement;// no comments

public:
  Base();
};
#endif
